package com.ssuu.ssuusnow.project.manage.dict_data.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ssuu.ssuusnow.model.result.ResultVo;
import com.ssuu.ssuusnow.project.manage.dict_data.entity.DictData;
import com.ssuu.ssuusnow.project.manage.dict_data.service.impl.DictDataServiceImpl;
import com.ssuu.ssuusnow.project.manage.dict_type.entity.DictType;
import com.ssuu.ssuusnow.project.manage.dict_type.service.impl.DictTypeServiceImpl;
import com.ssuu.ssuusnow.utils.log.LogPrint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 字典数据 前端控制器
 * </p>
 *
 * @author sun
 * @since 2023-06-14
 */
@RestController
@CrossOrigin
@RequestMapping("/dictData")
@Api(value = "字典数据",tags = "字典数据")
@ApiSupport(author = "孙")
public class DictDataController {
    @Resource
    DictDataServiceImpl service;
    @PostMapping("/add")
    @LogPrint("新增字典数据")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","updateby","isdel"})
    @ApiOperation(value = "新增字典数据",notes = "新增字典数据")
    public ResultVo add(@RequestBody DictData u) {
        return new ResultVo(service.AddTo(u));
    }
    @PutMapping("/update")
    @LogPrint("修改字典数据")
    @ApiOperationSupport(ignoreParameters = {"createTime","updateTime","updateby","isdel"})
    @ApiOperation(value = "修改字典数据",notes = "修改字典数据")
    public ResultVo update(@RequestBody DictData u) {
        return new ResultVo(service.UpdateTo(u));
    }
    @DeleteMapping("/del/{id}")
    @LogPrint("删除字典数据")
    @ApiOperation(value = "删除字典数据",notes = "删除字典数据")
    public ResultVo del(@NotNull(message="id不能为空") @PathVariable(value="id") Long id) {
        return new ResultVo(service.DelTo(id));
    }
    @GetMapping("/getlist")
    @LogPrint("查询字典数据")
    @ApiOperation(value = "查询字典数据",notes = "查询字典数据")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","updateby","isdel"})
    public ResultVo get(DictData u) {
        return new ResultVo(service.listTo(u));
    }
}
